/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CosBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Cos;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Entry.EntryType;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_63722
/*    */   extends UpgradeOp
/*    */ {
/*    */   private static final String ATTR_NAME = "zimbraPrefGalAutoCompleteEnabled";
/*    */   private static final String OLD_VALUE = "FALSE";
/*    */   private static final String NEW_VALUE = "TRUE";
/*    */   
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 42 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 44 */       doDefaultCos(zlc);
/*    */     } finally {
/* 46 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   Description getDescription()
/*    */   {
/* 52 */     return new Description(this, new String[] { "zimbraPrefGalAutoCompleteEnabled" }, new Entry.EntryType[] { Entry.EntryType.COS }, "FALSE", "TRUE", "Upgrades only the default cos.");
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   private void doEntry(ZLdapContext zlc, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 61 */     String entryName = entry.getLabel();
/*    */     
/* 63 */     this.printer.println();
/* 64 */     this.printer.println("------------------------------");
/* 65 */     this.printer.println("Checking zimbraPrefGalAutoCompleteEnabled on " + entryName);
/*    */     
/* 67 */     String curValue = entry.getAttr("zimbraPrefGalAutoCompleteEnabled", false);
/* 68 */     if ("FALSE".equals(curValue)) {
/* 69 */       this.printer.println("    Changing zimbraPrefGalAutoCompleteEnabled on " + entryName + " from " + curValue + " to " + "TRUE");
/*    */       
/*    */ 
/* 72 */       Map<String, Object> attr = new HashMap();
/* 73 */       attr.put("zimbraPrefGalAutoCompleteEnabled", "TRUE");
/*    */       try {
/* 75 */         modifyAttrs(zlc, entry, attr);
/*    */       }
/*    */       catch (ServiceException e) {
/* 78 */         this.printer.println("Caught ServiceException while modifying " + entryName + " attribute " + attr);
/* 79 */         this.printer.printStackTrace(e);
/*    */       }
/*    */     } else {
/* 82 */       this.printer.println("    Current value of zimbraPrefGalAutoCompleteEnabled on " + entryName + " is " + curValue + " - not changed");
/*    */     }
/*    */   }
/*    */   
/*    */   private void doDefaultCos(ZLdapContext zlc) throws ServiceException
/*    */   {
/* 88 */     Cos cos = this.prov.get(Key.CosBy.name, "default");
/* 89 */     if (cos != null) {
/* 90 */       doEntry(zlc, cos);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_63722.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */